package CalcImpl;

import java.io.FileWriter;

import org.omg.CORBA.ORB;
import org.omg.PortableServer.POA;
import org.omg.PortableServer.POAHelper;

public class CalcServer {
	public static void main(String args[]) {
		try{
	
			ORB orb = ORB.init(args, null);
			POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
			rootpoa.the_POAManager().activate();
	
			CalculatriceImpl c = new CalculatriceImpl();
	
			org.omg.CORBA.Object ref = rootpoa.servant_to_reference(c);      
			      
			String IORenString = orb.object_to_string(ref);
			FileWriter fw = new FileWriter("FicPourIOR");
			fw.write(IORenString);
			fw.close();
			System.out.println("server ready...");
			orb.run();
		}
	
		catch (Exception e) {
			System.err.println("ERROR: " + e);
			e.printStackTrace(System.out);
		}
	}
}
